﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using DQYT.HTDZ.Model;
using DQYT.HTDZ.OracleDAL;
using DQYT.HTDZ.BLL;

namespace DQYT.HTDZ.Web
{
    public class Globals
    {
        public static BDUserModel CurrentUserInfo
        {
            get
            {
                if (HttpContext.Current == null)
                    return null;

                BDUserModel userinfo = (BDUserModel)HttpContext.Current.Session[SessionName.CurrentUserInfo];
                if (userinfo != null)
                    return userinfo;
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    BDUserModel mUser = new BDUserModel();
                    BDUserBLL userBLL = new BDUserBLL();
                    userinfo = userBLL.GetModel(HttpContext.Current.User.Identity.Name);
                    Globals.CurrentUserInfo = userinfo;
                    return userinfo;
                }
                return null;
            }
            set
            {
                if (HttpContext.Current == null)
                    return;
                HttpContext.Current.Session[SessionName.CurrentUserInfo] = value;
            }
        }
    }

    public class SessionName
    {
        /// <summary>
        /// 保存当前登陆的用户信息，存放的是Ebest.Model.USERINFO
        /// </summary>
        public const string CurrentUserInfo = "CurrentUserInfo";

        public const string CurrUserBumen = "CurrUserBumen";
    }
}